package com.feigncloud.order.controller;

import com.feigncloud.order.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value="/consumer/payment/get/{id}")
    public Object getPaymentById(@PathVariable("id")  Long id) {
        return  paymentFeignService.getPaymentById(id);
    }

    /**
     * 通过feign调用支付模块
     * 默认时间1s，需要在yml文件配置时间
     * @return
     * 报错：
     * Read timed out executing GET http://cloud-consul-consumer-payment/payment/feign/timeout
     * feign.RetryableException: Read timed out executing GET http://cloud-consul-consumer-payment/payment/feign/timeout
     */
    @GetMapping(value = "/consumer/payment/feign/timeout")
    public Object paymentFeiginTimeOut(){
        log.info("通过feign调用payment的超时接口");
        String s = paymentFeignService.paymentFeignTimeout();
        return s;
    }
}
